home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / misc / emu / QDOS2.lha / QLsource / ROMsrc / SYS / STARTUP_asm < prev    next >
Text File  |  1995-05-14  |  6KB  |  221 lines

  1. */beginfile STARTUP_asm
  2. ; --------------------------------------------------------------
  3. ; STARTUP_asm - startup routines
  4. ;         - last modified 15/05/95
  5. ; QDOS-Amiga sources by Rainer Kowallik
  6. ;    ...some changes by Mark J Swift
  7. ; --------------------------------------------------------------
  8. ;*/beginoverlay
  9.  
  10. ; --------------------------------------------------------------
  11. ; Target for Jumps to reset the system
  12.  
  13. RST_SYS:
  14. SYS_STARt:
  15. QL_START:
  16. ; clear QL screen
  17.     lea    $20000,a0
  18.     move.w    #$1FFF,d0
  19. CLR_SCR:
  20.     clr.l    (a0)+
  21.     dbra    d0,CLR_SCR
  22. ;
  23.     dc.l    $2E780000    ; move.l $0,a7 Get SSP !A68k
  24.     move.l    a7,d0        ; Calculate start of
  25.     andi.w    #-$8000,d0    ; system variables
  26.     move.l    d0,a6
  27. ; set system system stack and lomem
  28.     lea    $480(a6),a7    ; Set SSP.
  29.     move.l    a7,a4        ; Set lomem.
  30.  
  31.     cmpi.w    #SV.IDENT,(a6)    ; Check if sys vars exist
  32.     bne.s    QDOS256K
  33. ; get himem from system variables
  34.     move.l    SV_RAMT(a6),a5    ; Get ramtop.
  35.     cmpa.l    a4,a5        ; use only if valid
  36.     bgt.s    CLR_VAR
  37. ; if lomem and himem not valid, can only assume a minimum system
  38. QDOS256K:
  39.     move.l    a0,a6        ; Put sys vars after scrn#1
  40.     lea    $480(a6),a7    ; Set SSP.
  41.     move.l    a7,a4        ; Set lomem.
  42.     lea    $60000,a5    ; Set ramtop
  43. ; clear system variables.
  44. CLR_VAR:
  45.     move.l    a6,a0        ; Start of memory to clear.
  46. CLR_VMEM:
  47.     clr.l    (a0)+
  48.     cmpa.l    a7,a0
  49.     bne.s    CLR_VMEM
  50. ; clear system memory, lomem to himem
  51. ;CLR_SYS:
  52. ;     move.l     a4,a0         ; Get start of ram.
  53. ;CLR_SMEM:
  54. ;     clr.l     (a0)+
  55. ;     cmpa.l     a5,a0         ; Clear until end of ram.
  56. ;     bne.s     CLR_SMEM
  57. ; initialise QL hardware registers
  58.     move.b    #$8,MC_STAT    ; 8 colour mode, screen #1
  59. ; initialise system variables.
  60. INISYVAR:
  61.     move.w    #SV.IDENT,(a6)    ; Store QDOS id.
  62.  
  63.     bsr    SET_ATTN     ; check processor type
  64.     bsr    CLRALL        ; clear data & instr caches
  65.  
  66.     move.l    a5,SV_RAMT(a6)    ; Store ramtop
  67.     move.l    a5,SV_RESPR(a6)    ; base of resident procs
  68.     move.l    a5,SV_TRNSP(a6)    ; base of transient progs
  69.     move.b    #-$40,SV_PCINT(a6) ; Current value for PC
  70.                  ; interrupt flag.
  71.  
  72. ; initialise pointers to slave blocks.
  73.     move.l    a5,d0        ; Top of ram.
  74.     bsr.s    SLVTBL_LEN    ; Max len of slave blk table
  75.     move.l    a7,a2        ; First byte after sys vars
  76.     lea    SV_BTPNT(a6),a3    ; Address of ptr to most
  77.                 ; recent slave block.
  78.     moveq    #0,d6
  79.     bsr.s    INI_TABLE    ; Initialise pointers to
  80.                 ; slave blocks.
  81. ; find combined length of job and channel tables.
  82.     move.l    a5,a0        ; Get himem.
  83.     suba.l    a4,a0        ; subtract lomem
  84.     move.l    a0,d0        ; Tables are at most 1/128th
  85.     lsr.l    #7,d0        ; the size of available ram
  86.     addi.l    #$80,d0        ; ...but big enough for at
  87.                 ; least 8 jobs.
  88.     bsr.s    LIMIT_TBLS    ; Limit table size to 120
  89.                 ; jobs and 360 channels.
  90. ; tables must finish on a 512 byte boundary
  91.     add.l    a2,d0        ; Make sure tables finish
  92.     addi.l    #$1FF,d0     ; on a 512 byte boundary
  93.     andi.w    #-$200,d0    ; by tweaking the combined
  94.     sub.l    a2,d0        ; length of channel and job
  95.     move.l    d0,d1        ; tables. Length in d0 & d1
  96.     bsr.s    LIMIT_TBLS    ; no more than 120 jobs.
  97.     lsr.l    #2,d0        ; New length of job table
  98.     sub.l    d0,d1        ; New length of channel tbl
  99.     move.l    a2,a0        ; Save start of job table.
  100. ;
  101.     moveq    #-$1,d6
  102.     clr.w    d6
  103.     lsl.l    #$8,d6        ; d6 = FF00 0000
  104. ; initialise job table.
  105.     bsr.s    INI_TABLE
  106. ; initialise channel table.
  107.     move.l    d1,d0
  108.     bsr.s    INI_TABLE
  109. ;
  110.     bra.s    LOW_USE
  111. ; subroutine to limit the combined lengths of job and channel
  112. ; tables to to that required for 120 jobs and 360 channels.
  113. LIMIT_TBLS:
  114.     moveq    #$78,d6
  115.     lsl.l    #4,d6        ; move.l   #$780,d6
  116.     cmp.l    d6,d0
  117.     bls.s    X_LIMIT
  118.     move.l    d6,d0
  119. X_LIMIT:
  120.     rts
  121. ; subroutine to return the maximum length of the slave block
  122. ; table given d0 as himem.
  123. SLVTBL_LEN:
  124.     addi.l    #$1FF,d0
  125. ; subroutine to find how far into the slave tables, the entry
  126. ; for memory address d0 is.
  127. SLVTBL_POS:
  128.     sub.l    a6,d0        ; Slave blocks start at the
  129.     andi.w    #-$200,d0    ; sys vars and are each 512
  130.     lsr.l    #6,d0        ; bytes long. Each table
  131.     rts            ; entry is 8 bytes long.
  132. ; subroutine to set slave, job or channel pointers.
  133. INI_TABLE:
  134.     move.l    a2,(a3)+     ; Current entry.
  135.     move.l    a2,(a3)+     ; Start of table.
  136.     lea    0(a2,d0.l),a0
  137. INI_TBL1:
  138.     move.l    d6,(a2)+
  139.     cmpa.l    a0,a2
  140.     blt.s    INI_TBL1
  141.     move.l    a2,(a3)+     ; End of table.
  142.     addq.l    #4,a3
  143.     rts
  144. ; continue by finding the lowest usable address.
  145. LOW_USE:
  146.     cmpa.l    a4,a2        ; which is greater, lomem
  147.     bgt.s    SET_LOW        ; or top of channel table?
  148.     move.l    a4,a2
  149. SET_LOW:
  150.     move.l    a2,SV_CHEAP(a6)    ; Set base of common heap.
  151.     move.l    a2,SV_FREE(a6)    ; Set base of free area.
  152.  
  153. ; find usable entries in the slave block table.
  154.     move.l    a2,d0        ; Find how many are used up
  155.     bsr.s    SLVTBL_LEN    ; by the tables themselves
  156.     move.l    d0,a2        ; Address of first free
  157.     adda.l    a7,a2        ; entry in ->a2.
  158.  
  159.     move.l    a5,a3        ; clear 512 bytes between
  160.     moveq    #$7F,d0        ; RAMTOP and base of BASIC
  161.                 ; stack
  162. CLRBASLUP:
  163.     clr.l    -(a3)
  164.     dbra    d0,CLRBASLUP
  165.  
  166.     move.l    a3,SV_BASIC(a6)    ; address of BASIC stack.
  167.  
  168.     move.l    a3,d0        ; Find address of first
  169.     bsr.s    SLVTBL_POS    ; entry made unusable by
  170.     move.l    d0,a3        ; BASIC stack in ->a3.
  171.     adda.l    a7,a3
  172.     move.l    a2,d0        ; Set SV.BTPNT half way
  173.     add.l    a3,d0        ; between the first unused
  174.     lsr.l    #4,d0        ; entry and the last, but
  175.     lsl.l    #3,d0        ; must be divisible by 8.
  176.     move.l    d0,SV_BTPNT(a6)    ; Store most recent block.
  177. ; initialise slave table entries.
  178.     moveq    #$1,d0
  179.     ror.l    #$8,d0        ; d0 = %0100 0000
  180. SLV_INIT:
  181.     move.l    d0,(a2)+     ; Put 0100 0000 0000 0000
  182.     clr.l    (a2)+        ; into entries for usable
  183.     cmpa.l    a3,a2        ; blocks.
  184.     blt.s    SLV_INIT
  185.     lea    BAS_STARt(pc),a1
  186.     LEA    SHLST(PC),A5
  187.     MOVE.L    A5,SV_SHLST(A6)    ; pointer to list of
  188.                 ; scheduler tasks
  189.     LEA    DRLST(PC),A5
  190.     MOVE.L    A5,SV_DRLST(A6)    ; pointer to list of device
  191.                 ; drivers
  192.     ADDQ.B    #1,SV_NETNR(A6)    ; network station number
  193.     ADDQ.B    #8,SV_MCSTA(A6)    ; current value of MC status
  194.                 ; register
  195.     MOVE.W    #$1E,SV_ARDEL(A6) ; auto repeat delay
  196.     ADDQ.W    #2,SV_ARFRQ(A6)    ; autorepeat 1/freq.
  197.     ADDQ.W    #3,SV_CQCH(A6)    ; ctrl. C
  198.     MOVE.L    #(MSG_LIST-ORG0),SV_MGTAB(A6) ; sys messages
  199.     MOVE.L    #(KEY_TRA-ORG0),SV_TRTAB(A6) ; key trnslation
  200. ; Initialise BASIC
  201.     MOVEA.L    SV_JBBAS(A6),A4    ; pointer to base of Job
  202.                 ; table
  203.     MOVE.L    A4,SV_JBPNT(A6)    ; pointer to current Job
  204.                 ; table entry
  205.     MOVEA.L    SV_TRNSP(A6),A3    ; base of transient program
  206.                 ; area
  207.     CLR.L    -(A3)
  208.     MOVEA.L    SV_BASIC(A6),A0    ; base of basic stack
  209.     MOVE.L    A0,(A4)        ; address of job 0: BASIC
  210.     MOVE.B    #$20,JB_PRINC(A0) ; BASIC's priority increment
  211.     MOVE.L    A3,USP
  212.     LEA    JB_END(A0),A6
  213.     MOVEA.L    A3,A5
  214.     SUBA.L    A6,A5        ; A5 = Basic area
  215.     move.w    #0,SR        ; user mode on
  216.     jmp    (a1)        ; start BASIC interpreter
  217.  
  218. ;*/endoverlay
  219. ; --------------------------------------------------------------
  220. ;*/endfile
  221.